<%@ page contentType="text/html;charset=UTF-8" %> 
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title><spring:message code="warehouse_shelves_createShelves"/></title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script type="text/javascript">
    
 
    $(document).ready(function(){
		 var form = $("#inputForm");  
	        form.validate();//验证指定的表单
	        
	        
	        	$("#createButton").click(function(){
	        		if (form.valid()) {//如果表单验证成功，则进行提交。  
	        			$("button").attr("disabled",true);
	        			createAccount();
	                	
	                return false
	              }
	         });
	        
	    });
   
		var shelvesCode;
		var shelvesBarCode;
    function createAccount(){
    	//获取 iframe 数量 
     	var frLength = window.parent.frames.length;
     	//父画面下标 
     	var parentIndex = frLength-2;
    	var frameObj = window.parent.frames[parentIndex].document.getElementById("parentTbody");
    	var index = $("#index").val();
    	if (index!=null && index!="") {
    	/* 删除该行  */
    		$(frameObj)[0].rows[index].remove();
			shelvesCode = $("#shelvesCode").val();
			shelvesBarCode = $("#shelvesBarCode").val();
			common();
		}else{
    		var params = $("#inputForm").serialize();
    		$.post("${ctx}/warehouse/message/getCode",params, function(result) {
				shelvesCode = result["shelvesCode"];
				shelvesBarCode = result["shelvesBarCode"];
				common();
    		}, 'json');
			
		}
    	//setTimeout(common, 150);
    }
    function common(){
    	//获取 iframe 数量 
     	var frLength = window.parent.frames.length;
     	//父画面下标 
     	var parentIndex = frLength-2;
    	/* 追加新的一行 */
    	var frameObj = window.parent.frames[parentIndex].document.getElementById("parentTbody");
    	var shelvesId = $("#shelvesId").val();
		var shelvesName = $("#shelvesName").val();
		var shelvesPlace = $("#shelvesPlace").val();
		var shelvesRemark = $("#shelvesRemark").val();
		var shelvesStatus = $("input:radio:checked").val();
		var yesOrNo ;
		if (shelvesStatus==1) {
			yesOrNo = "<spring:message code="warehouse_shelves_open"/>";
		}else{
			yesOrNo = "<spring:message code="warehouse_shelves_close"/>";
		}
		var userName = $("#userName").val();
		var createShelvesDate = $("#createShelvesDate").val().toString();
		var createShelvesDateDB = getMoth($("#createShelvesDateDB").val());
		var createShelvesUser = $("#createShelvesUser").val().toString();
		var newhidden = '<input type="hidden" id="shelvesIdList" name="shelvesIdList" value="'+shelvesId+'"><input type="hidden" id="deleteFlagHere" name="deleteFlagHere" value="0"><input type="hidden" id="shelvesCodeHere" name="shelvesCodeHere" value="'+shelvesCode+'"><input type="hidden" id="shelvesBarCodeHere" name="shelvesBarCodeHere" value="'+shelvesBarCode+'"><input type="hidden" id="shelvesNameHere" name="shelvesNameHere" value="'+shelvesName+'"><input type="hidden" id="shelvesPlaceHere" name="shelvesPlaceHere" value="'+shelvesPlace+'"><input type="hidden" id="shelvesRemarkHere" name="shelvesRemarkHere" value="'+shelvesRemark+'"><input type="hidden" id="shelvesStatusHere" name="shelvesStatusHere" value="'+shelvesStatus+'"><input type="hidden" id="createShelvesUserHere" name="createShelvesUserHere" value="'+createShelvesUser+'"><input type="hidden" id="createShelvesDateHere" name="createShelvesDateHere" value="'+createShelvesDate+'">';
		var newRow = '<tr><td class="table-ckhjcz"><img src="${ctxStatic}/images/btn-bj.png" onclick="addShelvesCheck(this);" height="25" width="25" />&nbsp;<img src="${ctxStatic}/images/btn-sc.png" height="25" width="25"  onclick="deleteCurrentRow(this)"/></td><td class="table-ckhjbm" >'+shelvesCode+'</td><td class="table-ckhjtxm" align="center"><div class="divBar">'+shelvesBarCode+'</div></td><td class="table-ckhjmc" >'+shelvesName+'</td><td class="table-ckhjwz" >'+shelvesPlace+'</td><td class="table-ckhjzt">'+yesOrNo+'</td><td class="table-ckhjms">'+shelvesRemark+'</td><td class="table-ckhjcjr" >'+userName+'</td><td class="table-ckhjcjsj" >'+createShelvesDateDB+'</td>'+newhidden+'</tr>';
		$(frameObj).prepend(newRow);
		window.parent.frames[parentIndex].barCode();
		closeWin();
    }
    </script>
</head>
<body>
<form id="inputForm">   
<div class="layerHeader clearfix">
<c:choose>
    <c:when test="${warehouseShelves.index!=null && warehouseShelves.index!='' }">
    		<p class="headerTitle"><spring:message code="warehouse_shelves_editShelves"/></p>
    </c:when>
      <c:otherwise>
      		<p class="headerTitle"><spring:message code="warehouse_shelves_createShelves"/></p>
      </c:otherwise>  
    </c:choose>
	
    <div class="headerButton clearfix">
    <c:choose>
    <c:when test="${warehouseShelves.index!=null && warehouseShelves.index!='' }">
    <shiro:hasPermission name="warehouse:message:view">
    		<button type="button" id="createButton"><spring:message code="warehouse_shelves_save"/></button>
    		</shiro:hasPermission>
    </c:when>
      <c:otherwise>
      <shiro:hasPermission name="warehouse:message:view">
      		<button type="button" id="createButton"><spring:message code="warehouse_shelves_create"/></button>
      		</shiro:hasPermission>
      </c:otherwise>  
    </c:choose>
        <button type="button" onclick="closeWin()"><spring:message code="warehouse_shelves_cancle"/></button>
    </div>
</div>

<div class="tabBoxSm">
    <div class="tabSm smOrderBox">
    	<input type="hidden" id="shelvesId" name="shelvesId" value="${warehouseShelves.shelvesId}">
        <input type="hidden" id="createShelvesDate" name="createShelvesDate" value="${fns:getDate('yyyy-MM-dd HH:mm')}">
    	<input type="hidden" id="createShelvesUser" name="createShelvesUser" value="${fns:getUser()}">
    	<input type="hidden" id="createShelvesDateDB" name="createShelvesDateDB" value="${fns:getDate('yyyy-MM-dd')}">
    	<input  type="hidden" id="userName" name="userName" value="${warehouseShelves.currentUser.firstName}${warehouseShelves.currentUser.lastName}">
    	<input type="hidden" id="index" name="index" value="${warehouseShelves.index}">
        <div class="clearfix">
        	<div class="left w-350">
            	<%-- <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="warehouse_shelves_code"/></p>--%>
                    <input type="hidden" id="shelvesCode" name="shelvesCode" value="${warehouseShelves.shelvesCode}">
                   <%--  <p class="haveTo">*</p>
                </div>--%>
               
                <%-- <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="warehouse_shelves_barCode"/></p>--%>
                    <input type="hidden" id="shelvesBarCode" name="shelvesBarCode" value="${warehouseShelves.shelvesBarCode}">
                   <%-- <p class="haveTo">*</p>
                </div> --%>
                
                <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="warehouse_shelves_name"/></p>
                    <input id="shelvesName" name="shelvesName" maxlength="100" value="${warehouseShelves.shelvesName}" data-rule-required="true" data-msg-required="<spring:message code="warehouse_shelves_err_msg_shelvesName"/>">
                    <p class="haveTo">*</p>
                </div>
                <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="warehouse_shelves_place"/></p>
                    <input id="shelvesPlace" name="shelvesPlace" maxlength="100" value="${warehouseShelves.shelvesPlace}" data-rule-required="true" data-msg-required="<spring:message code="warehouse_shelves_err_msg_shelvesPlace"/>">
                    <p class="haveTo">*</p>
                </div>
                <div class="items clearfix">
                	<p class="tit"><spring:message code="warehouse_shelves_status"/></p>
                				
                                    <div class="labelBox">
                                    <label>
                                        <input type="radio" style="width:20px;" id="yes" name="shelvesStatus" value="1"  <c:if test="${warehouseShelves.shelvesStatus eq 1 ||warehouseShelves.shelvesStatus eq null}"> checked="checked"</c:if>>
                                        <spring:message code="warehouse_create_open"/>
                                       </label>
                                       <label>
                                        <input type="radio" style="width:20px;" id="no" name="shelvesStatus" value="0"  <c:if test="${warehouseShelves.shelvesStatus eq 0}"> checked="checked"</c:if>>
                                        <spring:message code="warehouse_create_close"/>
                                   		</label>
                                   		</div>
                                  
                                  
                </div>
                <div class="items clearfix">
                	<p class="tit"><spring:message code="warehouse_shelves_remark"/></p>
                    <textarea id="shelvesRemark" name="shelvesRemark" style="width: 300px;height: 100px;">${warehouseShelves.shelvesRemark}</textarea>
                </div>
            </div>
           
       
        </div> 
	</div>
 </div>   
</form>
<script>
</script>
</body>
</html>
